package dao;

import entity.LinBoEntity;
import org.hibernate.transform.Transformers;
import org.springframework.orm.hibernate4.support.HibernateDaoSupport;
import org.springframework.stereotype.Component;

import org.hibernate.Query;;
import java.util.List;
@Component
public class LinBoDao extends HibernateDaoSupport {

    public List<LinBoEntity> query(String name){
        String sql = "select * from j05linbo where name like ? ";
        Query query=getSessionFactory().openSession().createSQLQuery(sql);
        query.setParameter(0,  "%" + name + "%");
        //将查询结果转成Map对象的集合
        // query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
        query.setResultTransformer(Transformers.aliasToBean(LinBoEntity.class));
        List<LinBoEntity> list=  query.list();
        return  query.list();
    }
}
//a